#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QtWebKitWidgets>
#include <QMessageBox>
#include <QFileDialog>
#include <QFileInfo>
#include <QComboBox>
#include <QPoint>
#include <QStringList>
#include <QTimer>
#include <QSpinBox>
#include <QFontDatabase>
#include "highlighters.h"
#include "themes.h"

struct TOpenFile {
    QString filename;
    bool modified;
    QPoint cursorPos;
    QString lines;
    QListWidgetItem *item;
};

class JSBridge : public QObject {
    Q_OBJECT

public:
    Q_INVOKABLE void SetCursorPos(const QString &col, const QString &row);
    Q_INVOKABLE void UpdateFileContents(const QVariant &contents);
    QPoint cursorPos;
    QList<TOpenFile> openFiles;
    bool insertActive;
    bool fileChanged;
    int ActiveFile;
};

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    QString base64_encode(QString string);
    QComboBox *listHighlighters;
    QComboBox *listThemes;
    QLabel *labelCol;
    QLabel *labelRow;
    QLabel *labelModified;
    QLabel *labelLineMode;
    QLabel *labelInsert;    
    QListWidget *listOpenFiles;
    QTimer *statusTimer;
    QComboBox *listFonts;
    QSpinBox *textFontSize;
    QToolBar *toolFindReplace;
    QLineEdit *textFind;
    QToolButton *btnCloseFind;
    QToolButton *btnNew;
    QToolButton *btnOpen;
    QToolButton *btnSave;
    QToolButton *btnFind;
    QToolButton *btnReplace;
    QToolButton *btnGoto;
    QToolButton *btnAbout;
    QToolButton *btnFindUp;
    QToolButton *btnFindDown;
    QString EditorPath;
    JSBridge bridge;
    QAceHighlighters highlighters;
    QAceThemes themes;

public slots:
   //void actionEvent(QAction* action);
   void populateJavaScriptWindowObject();
   void statusTimerUpdate();
   void listHighlightersIndexChanged(int index);
   void listThemesIndexChanged(int index);
   void listOpenFilesitemActivated(QListWidgetItem* item);
   void listFontsIndexChanged(int index);
   void textFontSizeValueChanged(int i);
   void OpenFileClick();
   void SaveFileClick();
   void NewFileClick();
   void AboutClick();
   void FindClick();
   void textFindTextChanged(QString str);

private:
   Ui::MainWindow *ui;
   QString selectHighlighter(QString filename);
   void SetTheme(int index);
   void PopulateFontCombo();

};



#endif // MAINWINDOW_H
